:- module(term_desc_page, [generate_term_description/1], [pillow, assertions,basicmodes]).

:- use_module(library(aggregates), [setof/3, (^)/2]).
:- use_module(library('pillow/pillow_types')).

:- use_module(search(utils), [remove_dir/2]).
:- use_module(portalfiles(standard_page), [standard_page/5]).
:- use_module(portalfiles(web_utils), [generate_box/2]).

:- include(which_match_to_use).

:- comment(module,"This module generates a HTML page showing the
	description of all dictionary terms included in the Amos
	database.").

:- pred generate_term_description(go(HTML)) :: html_term

# "Generates a HTML page with the description of all dictionary terms
	included in the Amos database.".

generate_term_description(HTML):-
        generate_box(box_term_desc_page, SB1),
 %%         make_sidebox(
 %%                      [div("Search Section"), nl,
 %%                       sub("Link1", b("What is this?")), nl,
 %%                       sub("Link2", "Search"), nl,
 %%                       sub("Link3", "Add Packages"), nl,
 %%                       sub("Link4", "Review Packages"), nl
 %%                      ], SB1),
        standard_page(all, "Term Description", 
                       SB1,
                       Body,
                       HTML),
        term_description_body(Body).


term_description_body(Body):-
     Body = [
           env(h1, [], ["Description of AMOS terms"]),
	   begin(table, [border="box"]),
	   begin(tbody),
	   AllTerms,
	   end(tbody),
	   end(table)
          ],
          (
          setof([begin(tr), td(b(TermStr)), td(TermDesc), end(tr)],
                ThisTerm^TermNameStr^Gen^(
                                          term_desc(ThisTerm, TermDesc, Gen),
                                          atom_codes(ThisTerm, TermNameStr),
                                          remove_dir(TermNameStr, TermStr)
                                      ),
                 AllTerms)
          ;
              AllTerms = []
          ), !.
                 

